package drexel.loading;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class LoadingQueue {

	private List queue = new ArrayList();
	
	private boolean done = false;
	
	public synchronized void addMovieFile(File file) {
		
		queue.add(file);
		
		notify();
	}
	
	public synchronized File getMovieFile() {
		
		while (!done && queue.isEmpty()) {
			
		      try {
		    	  
		        wait();
		        
		      } catch(InterruptedException ie) { }
		}
	
		if (!queue.isEmpty()) {
			
			return (File) queue.remove(0);
			
		} else {
			
			return null;
		}
	}
	
	public synchronized void done () {
		
		done = true;
		
		notify();
	}
}
